package com.tigerhhzz.smail.controller;

import com.tigerhhzz.smail.entity.Mail;
import com.tigerhhzz.smail.service.ProduceService;
import com.tigerhhzz.smail.service.SmsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/test")
public class TestController {

    @Autowired
    private ProduceService testService;

    @Autowired
    private SmsService smsService;

    @PostMapping("send")
    public boolean sendMail(Mail mail) {
        return testService.sendByAuto(mail);
    }

    /**
     * 获取短信验证码
     * @param mobile
     */
    @RequestMapping(value="/sendsms/{mobile}",method= RequestMethod.POST)
    public boolean sendsms(@PathVariable String mobile ){
        String code = smsService.sendSms(mobile);
        System.out.println("手机号：" +mobile+";验证码："+code+"；发送短信验证码成功");
        return true;
    }

}